home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / PScreateKeyableUI.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  10.1 KB  |  400 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Nov. 96
  22. //  Author:         hmbw
  23. //
  24. // Description:
  25. //    This script creates a window that can be used to
  26. //    set the keyable status of attributes on active objects.
  27. //
  28. //  Input Arguments:
  29. //      None.
  30. //
  31. //  Return Value:
  32. //      None.
  33. //
  34. //
  35.  
  36. global proc PSupdateKeyableUI ( string $parent, string $selectedItem )
  37. //
  38. // Setup the two lists of attributes - those that
  39. // are keyable, and those that aren't, so the user
  40. // can flip them from one side to the other.
  41. //
  42. {
  43.     setParent $parent;
  44.  
  45.     int $KEYABLE_List_Limit, $NONKEYABLE_List_Limit;
  46.     string $KEYABLE_List[], $NONKEYABLE_List[];
  47.  
  48.     $KEYABLE_List = `listAttr -k -s -v -r -w -c -m $selectedItem`;
  49.     $NONKEYABLE_List = `listAttr -s -v -r -w -c -m $selectedItem`;
  50.     $KEYABLE_List_Limit = size( $KEYABLE_List );
  51.     $NONKEYABLE_List_Limit = size( $NONKEYABLE_List );
  52.  
  53.     $KEYABLE_List = sort($KEYABLE_List);
  54.     $NONKEYABLE_List = sort($NONKEYABLE_List);
  55.  
  56.     // Since listAttr is going to return the full attribute names
  57.     // we need, strip off any component parts of $selectedItem
  58.     // by tokenizing based on the "." character.
  59.     //
  60.     string $node, $buffer[];
  61.     tokenize( $selectedItem, ".", $buffer );
  62.     if( size( $buffer ) > 0 ) {
  63.         $node = $buffer[0];
  64.     } else {
  65.         $node = $selectedItem;
  66.     }
  67.  
  68.     // First clear, then refill the keyable and 
  69.     // non-keyable scroll lists
  70.     //
  71.  
  72.     textScrollList -e -m 0 KEYABLE_List;
  73.     textScrollList -e -m 0 NONKEYABLE_List;
  74.  
  75.     textScrollList -e -ra KEYABLE_List;
  76.     textScrollList -e -ra NONKEYABLE_List;
  77.  
  78.     int $i;
  79.     for ( $i=0; $i < $KEYABLE_List_Limit; $i++ )
  80.     {
  81.         textScrollList -e -a $KEYABLE_List[$i] KEYABLE_List;
  82.     }
  83.  
  84.     for ( $i=0; $i < $NONKEYABLE_List_Limit; $i++ )
  85.     {
  86.         int     $isKeyable;
  87.         string  $attrName = ( $node + "." + $NONKEYABLE_List[$i] );
  88.  
  89.         if( !catch( $isKeyable = `getAttr -k $attrName` ) 
  90.         &&( $isKeyable == 0 ) )
  91.         {                    
  92.             textScrollList -e -a $NONKEYABLE_List[$i] NONKEYABLE_List;
  93.         }
  94.     }
  95.  
  96.     textScrollList -e -m 1 KEYABLE_List;
  97.     textScrollList -e -m 1 NONKEYABLE_List;
  98.  
  99.     // Hook up the buttons to the right object
  100.     //
  101.     button -e 
  102.         -c ( "PS_moveToNonKeyable " + $parent + " " + $selectedItem )
  103.         NONKEYABLE_Button;
  104.     button -e
  105.         -c ( "PS_moveToKeyable " + $parent + " " + $selectedItem )
  106.         KEYABLE_Button;
  107.  
  108.     // Dim the lock and unlock buttons.  They will be undimmed when
  109.     // the user clicks on either list
  110.     //
  111.     disable KEYABLE_Button;
  112.     disable NONKEYABLE_Button;
  113. }
  114. /*
  115. global proc addSorted(string $item, string $list)
  116. {
  117.     int $numItems = `textScrollList -q -ni $list`;
  118.     string $items[] = `textScrollList -q -ai $list`;
  119.     int $i;
  120.     int $successfull =0;
  121.  
  122.     if ($numItems == 0) {
  123.         textScrollList -e -a $item $list;
  124.         $successfull=1;
  125.     }
  126.  
  127.     for ($i = 0; $i < $numItems; $i++) {
  128.         if (strLess($item,$items[$i])) {
  129.             textScrollList -e -ap ($i+1) $item $list;
  130.             $successfull = 1;
  131.             break;
  132.         }
  133.     }
  134.     if (!$successfull)
  135.         textScrollList -e -a $item $list;
  136. }
  137. */
  138.  
  139. global proc PS_moveToKeyable ( string $parent, string $selectedItem )
  140. //
  141. // Move items selected in the non-keyable list
  142. // to the keyable list...
  143. //
  144. {
  145.     setParent $parent;
  146.  
  147.     int $selectedAttrsSize;
  148.     string $selectedAttrs[];
  149.  
  150.     $selectedAttrs = `textScrollList -q -si NONKEYABLE_List`;
  151.     $selectedAttrsSize = size( $selectedAttrs );
  152.  
  153.     // Since listAttr is going to return the full attribute names
  154.     // we need, strip off any component parts of $selectedItem
  155.     // by tokenizing based on the "." character.
  156.     //
  157.     string $node, $buffer[];
  158.     tokenize( $selectedItem, ".", $buffer );
  159.     if( size( $buffer ) > 0 ) {
  160.         $node = $buffer[0];
  161.     } else {
  162.         $node = $selectedItem;
  163.     }
  164.  
  165.     // see if the ALL option is engaged
  166.     //
  167.     int $changeAll = `checkBox -q -v CC_KEYALL_Box`;
  168.  
  169.     if ( $changeAll ){
  170.         // get the node type of the current node
  171.         //
  172.         string $baseType = `nodeType $selectedItem`;
  173.  
  174.         // get a list of all selected nodes
  175.         //
  176.         string $allNodes[] = `selectedNodes`;
  177.  
  178.         // for each node that matches type, set the keyability
  179.         // of each attribute in the non-keyable list
  180.         //
  181.         int $limit = `size($allNodes)`;
  182.         string $thisNode;
  183.         int $index;
  184.         for ( $index=0; $index<$limit; $index++ ){
  185.             $thisNode = $allNodes[$index];
  186.             if ( `nodeType $thisNode` == $baseType ){
  187.                 int $i;
  188.                 for ( $i=0; $i<$selectedAttrsSize; $i++ ){
  189.                     setAttr -k on ( $thisNode + "." + $selectedAttrs[$i] );
  190.                 }
  191.             }
  192.         }
  193.     } else {  // only change the selected node
  194.  
  195.         int $i;
  196.         for( $i=0; $i < $selectedAttrsSize; $i++ )
  197.         {
  198.             setAttr -k on ( $node + "." + $selectedAttrs[$i] );
  199.         }
  200.     }
  201.  
  202.     // Update the window
  203.     //
  204.     PSupdateKeyableUI $parent $selectedItem;
  205. }
  206.  
  207.  
  208. global proc PS_moveToNonKeyable ( string $parent, string $selectedItem )
  209. //
  210. // Move items selected in the keyable list
  211. // to the non-keyable list...
  212. //
  213. {
  214.     setParent $parent;
  215.     
  216.     int $selectedAttrsSize;
  217.     string $selectedAttrs[];
  218.  
  219.     $selectedAttrs = `textScrollList -q -si KEYABLE_List`;
  220.     $selectedAttrsSize = size( $selectedAttrs );
  221.  
  222.     // Since listAttr is going to return the full attribute names
  223.     // we need, strip off any component parts of $selectedItem
  224.     // by tokenizing based on the "." character.
  225.     //
  226.     string $node, $buffer[];
  227.     tokenize( $selectedItem, ".", $buffer );
  228.     if( size( $buffer ) > 0 ) {
  229.         $node = $buffer[0];
  230.     } else {
  231.         $node = $selectedItem;
  232.     }
  233.  
  234.     // see if the ALL option is engaged
  235.     //
  236.     int $changeAll = `checkBox -q -v CC_KEYALL_Box`;
  237.  
  238.     if ( $changeAll ){
  239.         // get the node type of the current node
  240.         //
  241.         string $baseType = `nodeType $selectedItem`;
  242.  
  243.         // get a list of all selected nodes
  244.         //
  245.         string $allNodes[] = `selectedNodes`;
  246.  
  247.         // for each node that matches type, set the keyability
  248.         // of each attribute in the non-keyable list
  249.         //
  250.         int $limit = `size($allNodes)`;
  251.         string $thisNode;
  252.         int $index;
  253.         for ( $index=0; $index<$limit; $index++ ){
  254.             $thisNode = $allNodes[$index];
  255.             if ( `nodeType $thisNode` == $baseType ){
  256.                 int $i;
  257.                 for ( $i=0; $i<$selectedAttrsSize; $i++ ){
  258.                     setAttr -k off ( $thisNode + "." + $selectedAttrs[$i] );
  259.                 }
  260.             }
  261.         }
  262.     } else {  // only change the selected node
  263.         int $i;
  264.         for( $i=0; $i < $selectedAttrsSize; $i++ )
  265.         {
  266.             setAttr -k off ( $node + "." + $selectedAttrs[$i] );
  267.         }
  268.     }
  269.  
  270.     // Update the window
  271.     //
  272.     PSupdateKeyableUI $parent $selectedItem;
  273. }
  274.  
  275.  
  276. global proc PScreateKeyableUI( string $parent, string $node )
  277. //
  278. // Sets up a UI that shows all the DAG and
  279. // Shape nodes in the system, so that the 
  280. // user can set the keyable attributes for
  281. // them.
  282. //
  283. {
  284.     setParent $parent;
  285.  
  286.     string $myContainer = `formLayout containerForm`;
  287.  
  288.     text -l "Keyable" KEYABLE_Text;
  289.  
  290.     // Label the non-keyable area
  291.     //
  292.     text -l "Non Keyable" NONKEYABLE_Text;
  293.  
  294.     // Create the Move to non-keyable button
  295.     //
  296.     string $nkButton = `button -l "Move >>" 
  297.         -c ( "PS_moveToNonKeyable " + $parent + " " + $node )
  298.         -h 26
  299.         NONKEYABLE_Button`;
  300.  
  301.     // Create the Move to keyable button
  302.     //
  303.     string $kButton = `button -l "<< Move" 
  304.         -c ( "PS_moveToKeyable " + $parent + " " + $node )
  305.         -h 26
  306.         KEYABLE_Button`;
  307.  
  308.     // Create the cancel/close button
  309.     //
  310.     button -l "Close" -h 26 -c "deleteUI LockingKeyable" CLOSE_Button;
  311.  
  312.     // Create the ALL checkbox
  313.     //
  314.     if ( !`optionVar -exists CCkeyAllSame` ){
  315.         optionVar -intValue CCkeyAllSame 1;
  316.     }
  317.     checkBox
  318.         -l "Change all selected objects of the same type"
  319.         -v `optionVar -q CCkeyAllSame`
  320.         -cc "optionVar -intValue CCkeyAllSame #1"
  321.         CC_KEYALL_Box;
  322.  
  323.     // Create the keyable scroll list
  324.     //
  325.     textScrollList
  326.         -ams 1
  327.         -h 150
  328.         -sc ("disable KEYABLE_Button; disable -v false " + $nkButton + ";textScrollList -e -da NONKEYABLE_List" )
  329.         KEYABLE_List;
  330.  
  331.     // Create the non-keyable scroll list
  332.     //
  333.     textScrollList
  334.         -ams 1
  335.         -h 150
  336.         -sc ("disable NONKEYABLE_Button; disable -v false " + $kButton + ";textScrollList -e -da KEYABLE_List" )
  337.         NONKEYABLE_List;
  338.  
  339.     separator -style "in" -hr true KEYABLE_Sep;
  340.  
  341.     // Edit the form attachments
  342.     //
  343.  
  344.     formLayout -edit
  345.         -af KEYABLE_Text top 10 
  346.         -af KEYABLE_Text left 10
  347.         -ap KEYABLE_Text right 10 50
  348.         -an KEYABLE_Text bottom
  349.  
  350.         -af NONKEYABLE_Text top 10
  351.         -ap NONKEYABLE_Text left 10 50
  352.         -af NONKEYABLE_Text right 10 
  353.         -an NONKEYABLE_Text bottom
  354.  
  355.         -af KEYABLE_List top 30
  356.         -af KEYABLE_List left 10
  357.         -ap KEYABLE_List right 0 50
  358.         -ac KEYABLE_List bottom 10 KEYABLE_Sep
  359.  
  360.         -af NONKEYABLE_List top 30
  361.         -ap NONKEYABLE_List left 0 50
  362.         -af NONKEYABLE_List right 10
  363.         -ac NONKEYABLE_List bottom 10 KEYABLE_Sep
  364.  
  365.         -an KEYABLE_Sep top
  366.         -af KEYABLE_Sep left 0
  367.         -af KEYABLE_Sep right 0
  368.         -af KEYABLE_Sep bottom 60
  369.  
  370.         -an CC_KEYALL_Box top
  371.         -af CC_KEYALL_Box left 15
  372.         -af CC_KEYALL_Box bottom 30
  373.         -an CC_KEYALL_Box right
  374.  
  375.         -ac CLOSE_Button top 2 CC_KEYALL_Box
  376.         -ap CLOSE_Button right 2 66
  377.         -ap CLOSE_Button left 2 33
  378.         -af CLOSE_Button bottom 5
  379.  
  380.         -ac NONKEYABLE_Button top 2 CC_KEYALL_Box
  381.         -ap NONKEYABLE_Button right 2 33
  382.         -af NONKEYABLE_Button left 5
  383.         -af NONKEYABLE_Button bottom 5
  384.  
  385.         -ac KEYABLE_Button top 2 CC_KEYALL_Box
  386.         -ap KEYABLE_Button left 2 66
  387.         -af KEYABLE_Button right 5
  388.         -af KEYABLE_Button bottom 5
  389.  
  390.         $myContainer;
  391.  
  392.  
  393.     // Fill the scroll lists
  394.     // with the selected object's attributes
  395.     //
  396.  
  397.     PSupdateKeyableUI $parent $node;
  398.     showWindow;
  399. }
  400.